package main

import (
	"fmt"
	"runtime"
	"time"
)

//go run -race goroutine.go
func main() {
	var arr [20]int
	for i := 0; i < 20; i++ {
		go func(i int) {
			fmt.Printf("打印出: %d \n", i)
			for {
				arr[i]++
				runtime.Gosched()
			}
		}(i)
	}

	fmt.Println(arr)
	time.Sleep(time.Millisecond)
}
